import dayjs from "dayjs"
import utc from "dayjs/plugin/utc"

dayjs.extend(utc)

// toLocalTime 将时间转换为浏览器本地时间
export const toLocalTime = (t: string): string => {
    return dayjs(t).utc().local().format('YYYY-MM-DD HH:mm:ss Z')
}

// toLocalTimeByTimeSecond 将时间戳秒转为浏览器本地时间
export const toLocalTimeByTimeSecond = (t: number): string => {
    return dayjs.unix(t).utc().local().format('YYYY-MM-DD HH:mm:ss Z')
}

// curTimeUnix 返回当前的时间戳
export const curTimeUnix = (): number => {
    return dayjs().unix()
}
